/**
 * 
 */
package com.globalresources.dao.hibernate;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.globalresources.dao.inface.ICityDao;
import com.globalresources.po.City;

/**
 * @author Administrator
 *
 */
public class CityDaoHibernate extends HibernateDaoSupport implements ICityDao {

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.ICityDao#deleteCity(com.globalresources.po.City)
	 */
	public boolean deleteCity(City city) {
		// TODO Auto-generated method stub
		try{
			 getHibernateTemplate().delete(city);
			 
			 return true;
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.ICityDao#findAll()
	 */
	public List<City> findAll() {
		// TODO Auto-generated method stub
		return getHibernateTemplate().find("from City city order by city.id desc");
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.ICityDao#findBySql(java.lang.String)
	 */
	public List<City> findBySql(String sql) {
		// TODO Auto-generated method stub
		return getHibernateTemplate().find(sql);
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.ICityDao#saveCity(com.globalresources.po.City)
	 */
	public boolean saveCity(City city) {
		// TODO Auto-generated method stub
		try{
			 getHibernateTemplate().save(city);
			 return true;
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.ICityDao#saveOrUpdateCity(com.globalresources.po.City)
	 */
	public boolean saveOrUpdateCity(City city) {
		// TODO Auto-generated method stub
		try{
			 getHibernateTemplate().saveOrUpdate(city);
			 return true;
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
	}

}
